package com.sojson.project.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.sojson.base.impl.BaseDaoImpl;
import com.sojson.project.dao.ActivityDao;
import com.sojson.project.entity.po.Activity;
import com.sojson.project.entity.vo.ActivityVo;

/**
 * 活动表Dao实现类(目的:把分页插件从Service层分离,这样就不用每次调Dao接口都要分页)
 * 
 * @author liu
 * @date 2021-03-24
 */
@Repository
public class ActivityDaoImpl extends BaseDaoImpl<ActivityDao, Activity> implements ActivityDao {

    @Resource
    private ActivityDao activityDao;

    /**
     * 单条插入
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public int insert(Activity activity) {
        return activityDao.insert(activity);
    }

    /**
     * 批量插入
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public int insertList(List<Activity> activitys) {
        return activityDao.insertList(activitys);
    }

    /**
     * 通过对象批量删除(物理删除)
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByDto(Activity activity) {
        return activityDao.deleteByDto(activity);
    }

    /**
     * 统计全部数量
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public int countAll() {
        return activityDao.countAll();
    }

    /**
     * 查询所有
     * 
     * @return
     * @throws SQLException
     */
    @Override
    public List<Activity> listAll() {
        return activityDao.listAll();
    }

    /**
     * 根据对象统计数量
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public int countByDto(Activity activity) {
        return activityDao.countByDto(activity);
    }

    /**
     * 根据对象查询
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public List<Activity> listByDto(Activity activity) {
        startPageDefaultSort(activity);
        return activityDao.listByDto(activity);
    }

    /**
     * 通过id删除(物理删除)
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteById(Integer id) {
        return activityDao.deleteById(id);
    }

    /**
     * 通过id列表删除(物理删除)
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public int deleteByIdList(ArrayList<Integer> ids) {
        return activityDao.deleteByIdList(ids);
    }

    /**
     * 通过id更新(全部更新)
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public int updateById(Activity activity) {
        return activityDao.updateById(activity);
    }

    /**
     * 通过id列表更新(全部更新)(更新内容相同)
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticByIdList(Activity activity) {
        return activityDao.updateStaticByIdList(activity);
    }

    /**
     * 通过id列表更新(全部更新)(更新内容不相同)
     * 
     * @param activitys
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangeByIdList(ArrayList<Activity> activitys) {
        return activityDao.updateChangeByIdList(activitys);
    }

    /**
     * 通过id更新(局部更新)
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public int updatePartialById(Activity activity) {
        return activityDao.updatePartialById(activity);
    }

    /**
     * 通过id列表更新(局部更新)(更新内容相同)
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public int updateStaticPartialByIdList(Activity activity) {
        return activityDao.updateStaticPartialByIdList(activity);
    }

    /**
     * 通过id列表更新(局部更新)(更新内容不相同)
     * 
     * @param activitys
     * @return
     * @throws SQLException
     */
    @Override
    public int updateChangePartialByIdList(ArrayList<Activity> activitys) {
        return activityDao.updateChangePartialByIdList(activitys);
    }

    /**
     * 通过id查询
     * 
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public Activity findById(String id) {
        return activityDao.findById(id);
    }

    /**
     * 通过编号查询
     * 
     * @param no
     * @return
     * @throws SQLException
     */
    @Override
    public Activity findByNo(String no) {
        return activityDao.findByNo(no);
    }

    /**
     * 通过id列表查询
     * 
     * @param ids
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Activity> findByIdList(ArrayList<Integer> ids) {
        return activityDao.findByIdList(ids);
    }

    /**
     * 通过对象查询id列表
     * 
     * @param activity
     * @return
     * @throws SQLException
     */
    @Override
    public ArrayList<Integer> findIdByDto(Activity activity) {
        return activityDao.findIdByDto(activity);
    }

    /**
     * 清空数据(物理清空)
     * 
     * @throws SQLException
     */
    @Override
    public void clear() {
        activityDao.clear();
    }

    /**
     * 查看最后一个助力活动的结束时间
     * 
     * @return
     */
    @Override
    public Date findLastHelpEndTime() {
        return activityDao.findLastHelpEndTime();
    }

    /**
     * 获取当前时间的助力活动
     * 
     * @param date
     * @return
     */
    @Override
    public ActivityVo findThisHelp(Date date) {
        return activityDao.findThisHelp(date);
    }

    /**
     * 获取当前时间的活动
     * 
     * @return
     * @throws Exception 
     */
    @Override
    public List<ActivityVo> findThis(ActivityVo activity) {
        startPageDefaultSort(activity);
        return activityDao.findThis(activity);
    }

    /**
     * 获取当前时间的活动
     * 
     * @return
     * @throws Exception 
     */
    @Override
    public List<ActivityVo> findThisByUserNo(ActivityVo activity) {
        startPageDefaultSort(activity);
        return activityDao.findThisByUserNo(activity);
    }

    /**
     * 修改过期的活动状态
     * 
     * @return
     */
    @Override
    public int updateStatusToEnd(ActivityVo activity) {
        return activityDao.updateStatusToEnd(activity);
    }

}